package com.baizhi.service.impl;

import com.baizhi.entity.Cart;
import com.baizhi.entity.OrderMaster;
import com.baizhi.feign.OrderFeign;
import com.baizhi.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * @author yystart
 * @create 2019-10-05 0:17
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderFeign orderFeign;

    @Override
    public Map insert(OrderMaster master, HttpSession session) {
        Cart cart = (Cart) session.getAttribute("cart");
        Map map  = new HashMap();
        map.put("master",master);
        map.put("cart",cart);
        Map insert = orderFeign.insert(map);
        if((boolean)insert.get("isInsert")){
            session.removeAttribute("cart");
        }
        return insert;
    }
}
